<template>
  <a-drawer
    title="新增考场信息"
    width=450
    placement="right"
    :closable="false"
    @close="onClose"
    :visible="siteAddVisiable"
    style="height: calc(100% - 55px);overflow: auto;padding-bottom: 53px;">
    <a-form >
      <a-row :gutter="48">
          <a-col :sm="{span:24}" :lg="{span:12}"  >
            <a-form-item label="考区">
              <a-select :allowClear="true" v-model="postParams.zy" @change="yxChange">
                <a-select-option v-for="i in selectMenu.yx" :key="i.id" :value="i.dwh">{{ i.dwmc }}</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :sm="{span:24}" :lg="{span:12}"  >
            <a-form-item label="最大容量">
              <a-input-number placeholder="请输入..." v-model="postParams.kskm"/>
            </a-form-item>
          </a-col>
          <a-col :sm="{span:24}" :lg="{span:12}"  >
            <a-form-item label="考场名称">
              <a-input placeholder="请输入..." v-model="postParams.kskm"/>
            </a-form-item>
          </a-col>
           <a-col :sm="{span:24}" :lg="{span:12}"  >
            <a-form-item label="考生数量">
              <a-input-number placeholder="请输入..." v-model="postParams.kskm"/>
            </a-form-item>
          </a-col>
          <a-col :sm="{span:24}" :lg="{span:12}"  >
            <a-form-item label="监考老师人数">
              <a-input-number placeholder="请输入..." v-model="postParams.kskm"/>
            </a-form-item>
          </a-col>
          <a-col :sm="{span:24}" :lg="{span:12}"  >
            <a-form-item label="位置">
              <a-input placeholder="请输入..." v-model="postParams.kskm"/>
            </a-form-item>
          </a-col>
          <a-col :sm="{span:24}" :lg="{span:24}"  >
            <a-form-item label="备注">
              <a-textarea placeholder="请输入..." v-model="postParams.bz" :rows="4"/>
            </a-form-item>
          </a-col>
      </a-row>
    </a-form>
    <div class="drawer-bootom-button">
      <a-button style="margin-right: .8rem" @click="onClose">取消</a-button>
      <a-button @click="handleSubmit" type="primary" :loading="loading">保存</a-button>
    </div>
  </a-drawer>
</template>

<script>
// import moment from 'moment'
import { STable } from '~'
import { mapState } from 'vuex'

const formItemLayout = {
  labelCol: { span: 3 },
  wrapperCol: { span: 18 }
}

const selectArr = ['TYPE0126', 'TYPE0075', 'TYPE0125', 'TYPE0072']
export default {
  props: {
    siteAddVisiable: {
      default: false
    }
  },
  components: {
    STable
  },
  data () {
    return {
      formItemLayout,
      loading: false,
      postParams: {},
      selectMenu: {
        yx: [] // 院系
      }
    }
  },
  computed: {
    ...mapState({
      systemInfo: state => state.app.systemInfo,
      TYPE0126: state => state.app['TYPE0126'] // 年级
    })
  },
  created () {
    this.initSelectMenu()
    selectArr.forEach(v => {
      this.$store.dispatch('app/setDictionary', v)
    })
  },
  methods: {
    initSelectMenu () {
      let allRequest = [
        this.$api.base.collegeAll()
      ]
      Promise.all(allRequest).then(res => {
        this.selectMenu = {
          yx: res[0].data
        }
      })
    },
    reset () {
      this.data = []
    },
    // 选择院系
    yxChange (code) {
    },
    // 选择招生年度
    zsndChange () {

    },
    // 关闭
    onClose () {
      this.reset()
      this.$emit('close')
    },
    // 保存
    handleSubmit () {
      this.reset()
      this.$emit('success')
    },
    handleDelete (key) {
      const dataSource = [...this.data]
      this.data = dataSource.filter(item => item.key !== key)
    },
    // 改变时间
    handleDateChange () {

    }
  }
}
</script>
